package com.bnc.menu.schedule;


import java.awt.event.ActionListener;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

import com.bnc.dto.PlanDTO;
import com.bnc.manager.JDBCManager;
import com.bnc.props.GlobalData;

public class writeAction  {

	private JDBCManager jdbcManager;
	private PreparedStatement pstmt;
	private String cd = Schedule.clickdate;
	
	public writeAction() {
		
		jdbcManager = JDBCManager.getInstance();
		String title = schedulePopup.titleTF.getText();
		String note = schedulePopup.storyTA.getText();
		
		
		String query = "INSERT INTO TBL_PLAN " +
		   "VALUES( ?, ?, ?, ?, ?, ?, TBL_PLAN_SEQ.nextval)";
		
		pstmt = jdbcManager.prepareStatement( query );
		
		try {
			pstmt.setString( 1, GlobalData.memberDTO.getId());
			pstmt.setString( 2, GlobalData.memberDTO.getName() );
			pstmt.setString( 3, cd);
			pstmt.setString( 4,  (String) schedulePopup.starttime.getSelectedItem()+"."+(String) schedulePopup.endtime.getSelectedItem());
			pstmt.setString( 5,  title);
			pstmt.setString( 6,  note);
			pstmt.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
				try {
					if(pstmt != null)
					pstmt.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}		
			
		}
		
	}

}


